import shutil, os

# def listdirs() -> list:
#     files = os.listdir()
#     for f in files:
#         if os.path.isdir(f):
#             files.remove(f)
    
#     return files

def folder_recursive(folder_handle, file_handle, folder:str):
    os.chdir(folder)
    files = os.listdir()
    for f in files:
        if os.path.isdir(f):
            folder_handle(file_handle, f)
        else:
            file_handle(f)
    os.chdir('..')

def clean_Debug_folder(file_handle, f):
    if f == "Debug":
        shutil.rmtree(f, True)
    else:
        folder_recursive(clean_Debug_folder, file_handle, f)


def clean_output(file:str):
    if file.split('.')[-1] in ['out', 'exe', 'obj', 'user']:
        os.remove(file)


folder_recursive(clean_Debug_folder, clean_output, '.')